﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using VCommons;

namespace Common.Background.WebUI
{
    // 注意: 有关启用 IIS6 或 IIS7 经典模式的说明，
    // 请访问 http://go.microsoft.com/?LinkId=9394801

    public class MvcApplication : System.Web.HttpApplication
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute(
                     "Default", // 路由名称
                     "{controller}/{action}.shtml", // 带有参数的 URL
                     new { controller = "account", action = "MenuManage" } // 参数默认值
                 );
            routes.MapRoute(
                "Default0", // 路由名称
                "{controller}/{action}/{id}.shtml", // 带有参数的 URL
                new { controller = "account", action = "MenuManage", id = UrlParameter.Optional } // 参数默认值
            );

            routes.MapRoute(
               "Defaultb1", // 路由名称
               "{controller}/{action}", // 带有参数的 URL
               new { controller = "account", action = "MenuManage" } // 参数默认值
           );
            routes.MapRoute(
             "Defaultb2", // 路由名称
             "{controller}/{action}/{id}", // 带有参数的 URL
             new { controller = "account", action = "MenuManage" } // 参数默认值
         );

        }

        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            RegisterRoutes(RouteTable.Routes);
        }


        protected void Session_Start()
        {

            if (string.IsNullOrEmpty(SessionAction.ReadSession("Background_Current_UserID")))
            {
                SessionAction.WriteSession("Background_Current_UserID", -new Random().Next(2, 99999));


                SessionAction.WriteSession("UserOperatorRole", "1");
            }
        }


    }
}